<?php
/**
* Details of an entry in [ images ]
*/

$images = new images();
$image_id = $variable->get('id', 'integer', 0); # Entity ID
$code = $variable->get('code', 'string', ''); # Protection Code

if(!$image_id)
{
	# Page was loaded without the ID parementer
	stopper::url('images-direct-access-error.php?context=identity');
}
else
{
	# Try to load the details
	if($images_details = $images->details($image_id, $code))
	{
		# We aim to reach here only.
		$smarty->assignByRef('images', $images_details);
	}
	else
	{
		# Record not found
		stopper::url('images-direct-access-error.php?context=data');
	}
}

$sizes_sql="
SELECT
	s.size_id,
	s.size_name,
	s.dimension_height,
	s.dimension_width,
	`is`.cropnail_x,
	`is`.cropnail_y,
	`is`.image_id,
	`is`.cropnail_xy
FROM gallery_images_sizes `is`
RIGHT OUTER JOIN gallery_sizes s ON
	`is`.size_id=s.size_id
	AND `is`.image_id={$image_id}
WHERE
	s.is_active='Y'
	AND s.is_approved='Y'
;";
$images_sizes = $images->arrays($sizes_sql);
$smarty->assignByRef('sizes', $images_sizes);
#print_r($images_sizes);

# For images preview, find out album ID
$smarty->assign('album_id', $images->album_id($image_id));
?>